<?php
	include('db.php');
	$timestamp = time();
	$timeout = $timestamp - 900;
	$IP=$_SERVER['REMOTE_ADDR'];
	$mem_query = "SELECT `member`  FROM `online` WHERE `member`=1";
	$mem_result = mysql_query($mem_query);
	$members = mysql_num_rows($mem_result);
	$guest_query = "SELECT member FROM `online` WHERE `member`=0";
	$guest_result = mysql_query($guest_query);
	$guests = mysql_num_rows($guest_result);
	$if_ip = "SELECT ip FROM `online` WHERE ip='$IP'";
	$if_ip = mysql_query($if_ip);
	$if_ip = mysql_num_rows($if_ip);
	if ($if_ip == '0')
	{
		$ins_query = "INSERT INTO `online`(id, ip, time, member, file) VALUES ('', '$IP', '$timestamp', '$member', '')";
		mysql_query($ins_query);
	}
	$del_query = "DELETE FROM online WHERE timestamp<$timeout";
	mysql_query($del_query);
	$users = $guests + $members;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>
	</title>
</head>
<body>
	<br />
	<table align="center">
		<tr>
			<td>
				Users Online
				<hr />
			</td>
		</tr>
		<tr>
			<td>
				Members:
				<?php
					echo "$members";
				?>
			</td>
			</tr>
		<tr>
			<td>
				Guests:
				<?php
					echo $guests;
				?>
			</td>
		</tr>
		<tr>
			<td>
				Total:
				<?php
					echo "$users";
				?>
			</td>
		</tr>
	</table>
</body>
</html>
